package com.gs.wechatdemo.util;

import android.media.MediaPlayer;

import java.io.IOException;

public class VoiceUtil {
    public static int getVoiceLength(String url){
        int length = 0;
        MediaPlayer mediaPlayer = new MediaPlayer();
        try {
            mediaPlayer.setDataSource(url);
            mediaPlayer.prepare();
            length =  mediaPlayer.getDuration()/1000;
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            mediaPlayer.release();
        }
        return length;
    }
}
